#include<bits/stdc++.h>
#define FUCK DIGIT DP
#define int long long
#define rep(i,a,b) for(int i(a);i<=(b);++i)
#define req(i,a,b) for(int i(a);i>=(b);--i)
using namespace std;
constexpr int mod=1'000'000'007;
int n,k,cnt[1001][1001][2][2],dp[1001][1001][2][2];
string dir,a,b;
signed main()
{
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	cin>>n>>k>>dir>>a>>b,dir=' '+dir;
	string a1="1",a2="1";rep(i,1,n-1) a1+=dir[i]=='L'?'0':'1',a2+=dir[i]=='L'?'1':'0';
	int ok1=a<=a1&&a1<=b,ok2=a<=a2&&a2<=b,ans=0;
	if(ok1)
	{
		int p1=0;
		for(auto ch:a1) p1=(p1*2+ch-48)%mod;ans+=p1;
	}
	if(ok2)
	{
		int p1=0;
		for(auto ch:a2) p1=(p1*2+ch-48)%mod;ans+=p1;
	}
	cout<<(ans%mod);
	/*
	{
		cnt[0][0][1][0]=1;
		dp[0][0][1][0]=1;
		rep(i,1,n-1) rep(j,0,k)
		{
			cnt[i][j][0][0]=a[i]=='1'?0:(j?cnt[i-1][j-1][dir[i]=='L'][0]:0)+cnt[i-1][j][dir[i]!='L'][0];
			dp[i][j][0][0]=(a[i]=='1'?0:(j?dp[i-1][j-1][dir[i]=='L'][0]:0)+dp[i-1][j][dir[i]!='L'][0])*2+(dir[i]=='R')*cnt[i][j][0][0];
			cnt[i][j][1][0]=a[i]=='0'?0:(j?cnt[i-1][j-1][dir[i]=='R'][0]:0)+cnt[i-1][j][dir[i]!='R'][0];
			dp[i][j][1][0]=(a[i]=='0'?0:(j?dp[i-1][j-1][dir[i]=='R'][0]:0)+dp[i-1][j][dir[i]!='R'][0])*2+(dir[i]=='L')*cnt[i][j][1][0];
			cnt[i][j][0][1]=(j?cnt[i-1][j-1][dir[i]=='L'][1]:0)+cnt[i-1][j][dir[i]!='L'][1];
			dp[i][j][0][1]=((j?dp[i-1][j-1][dir[i]=='L'][1]:0)+dp[i-1][j][dir[i]!='L'][1])*2+(dir[i]=='R')*cnt[i][j][0][1];
			cnt[i][j][1][1]=(j?cnt[i-1][j-1][dir[i]=='R'][1]:0)+cnt[i-1][j][dir[i]!='R'][1]+(a[i]=='1'?0:((j?cnt[i-1][j-1][dir[i]=='R'][0]:0)+cnt[i-1][j][dir[i]!='R'][0]));
			dp[i][j][1][1]=((j?dp[i-1][j-1][dir[i]=='R'][1]:0)+dp[i-1][j][dir[i]!='R'][1]+(a[i]=='1'?0:((j?dp[i-1][j-1][dir[i]=='R'][0]:0)+dp[i-1][j][dir[i]!='R'][0])))*2+(dir[i]=='L')*cnt[i][j][1][1];
			cnt[i][j][0][0]%=mod,cnt[i][j][0][1]%=mod,cnt[i][j][1][0]%=mod,cnt[i][j][1][1]%=mod,dp[i][j][0][0]%=mod,dp[i][j][0][1]%=mod,dp[i][j][1][0]%=mod,dp[i][j][1][1]%=mod;
			cout<<i<<" "<<j<<": "<<cnt[i][j][0][0]<<","<<dp[i][j][0][0]<<" "<<cnt[i][j][0][1]<<","<<dp[i][j][0][1]<<" "<<cnt[i][j][1][0]<<","<<dp[i][j][1][0]<<" "<<cnt[i][j][1][1]<<","<<dp[i][j][1][1]<<endl;
		}
	}
	int ansall=dp[n-1][k][0][0]+dp[n-1][k][0][1]+dp[n-1][k][1][0]+dp[n-1][k][1][1];
	{
		memset(cnt,0,sizeof(cnt)),memset(dp,0,sizeof(dp));
		cnt[0][0][0][0]=cnt[0][0][1][0]=1;
		dp[0][0][0][0]=dp[0][0][1][0]=1;
		rep(i,1,n-1) rep(j,0,k)
		{
			cnt[i][j][0][0]=b[i]=='1'?0:(j?cnt[i-1][j-1][dir[i]=='L'][0]:0)+cnt[i-1][j][dir[i]!='L'][0];
			dp[i][j][0][0]=(b[i]=='1'?0:(j?dp[i-1][j-1][dir[i]=='L'][0]:0)+dp[i-1][j][dir[i]!='L'][0])*2;
			cnt[i][j][1][0]=b[i]=='0'?0:(j?cnt[i-1][j-1][dir[i]=='R'][0]:0)+cnt[i-1][j][dir[i]!='R'][0];
			dp[i][j][1][0]=(b[i]=='0'?0:(j?dp[i-1][j-1][dir[i]=='R'][0]:0)+dp[i-1][j][dir[i]!='R'][0])*2+cnt[i][j][1][0];
			cnt[i][j][0][1]=(j?cnt[i-1][j-1][dir[i]=='L'][1]:0)+cnt[i-1][j][dir[i]!='L'][1];
			dp[i][j][0][1]=((j?dp[i-1][j-1][dir[i]=='L'][1]:0)+dp[i-1][j][dir[i]!='L'][1])*2;
			cnt[i][j][1][1]=(j?cnt[i-1][j-1][dir[i]=='R'][1]:0)+cnt[i-1][j][dir[i]!='R'][1]+(b[i]=='1'?0:(j?cnt[i-1][j-1][dir[i]=='R'][0]:0)+cnt[i-1][j][dir[i]!='R'][0]);
			dp[i][j][1][1]=((j?dp[i-1][j-1][dir[i]=='R'][1]:0)+dp[i-1][j][dir[i]!='R'][1]+(b[i]=='1'?0:(j?dp[i-1][j-1][dir[i]=='R'][0]:0)+dp[i-1][j][dir[i]!='R'][0]))*2+cnt[i][j][1][1];
			cnt[i][j][0][0]%=mod,cnt[i][j][0][1]%=mod,cnt[i][j][1][0]%=mod,cnt[i][j][1][1]%=mod,dp[i][j][0][0]%=mod,dp[i][j][0][1]%=mod,dp[i][j][1][0]%=mod,dp[i][j][1][1]%=mod;
			//cout<<i<<" "<<j<<": "<<cnt[i][j][0][0]<<","<<dp[i][j][0][0]<<" "<<cnt[i][j][0][1]<<","<<dp[i][j][0][1]<<" "<<cnt[i][j][1][0]<<","<<dp[i][j][1][0]<<" "<<cnt[i][j][1][1]<<","<<dp[i][j][1][1]<<endl;
		}
		ansall-=dp[n-1][k][0][1]+dp[n-1][k][1][0]+dp[n-1][k][1][1];
	}
	cout<<(((ansall%mod)+mod)%mod)<<endl;
	//cout<<cnt[n-1][k][0][0]<<" "<<cnt[n-1][k][0][1]<<" "<<cnt[n-1][k][1][0]<<" "<<cnt[n-1][k][1][1]<<endl;
	//cout<<dp[n-1][k][0][0]<<" "<<dp[n-1][k][0][1]<<" "<<dp[n-1][k][1][0]<<" "<<dp[n-1][k][1][1]<<endl;
	*/
	return 0;
}
